<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:o="http://openfaces.org/"
	xmlns:s="http://jboss.com/products/seam/taglib"
	template="/WEB-INF/esquema/permitTemplate.xhtml">

	<ui:define name="activityCustomContent">
		<h3>#{messages['options.workflow']}</h3>
		<br/>
		<a4j:commandLink value="#{messages['options.view_request']}"
			oncomplete="#{rich:component('viewPanel')}.show()">
			<f:setPropertyActionListener value="#{true}" target="#{viewPermitHelper.renderData}" />
		</a4j:commandLink>

		<br/>
		<br/>
		<br/>
		<rich:separator height="3px"/>
		<br/>
		
		<ui:include src="/permits/includes/viewPermitPanel.xhtml">
			<ui:param name="permitType" value="BUILDING_PERMIT" />
		</ui:include>
	</ui:define>

	<ui:define name="mainControls">
		<o:commandButton value="#{messages['permit.approve_permit']}" onclick="approvePermit();">
			<o:confirmation width="400px"
				message="#{messages['permit.approve_permit_msg']}. #{messages['button.continue']}?"
				caption="SIGIT"
				details=""
				okButtonText="#{messages['button.ok']}"
				cancelButtonText="#{messages['button.cancel']}">
			</o:confirmation>
		</o:commandButton>
		<o:commandButton value="#{messages['permit.deny_permit']}" onclick="denyPermit();">
			<o:confirmation width="400px"
				message="#{messages['permit.deny_permit_msg']}. #{messages['button.continue']}?"
				caption="SIGIT"
				details=""
				okButtonText="#{messages['button.ok']}"
				cancelButtonText="#{messages['button.cancel']}">
			</o:confirmation>
		</o:commandButton>
		<o:commandButton value="#{messages['button.l8r']}" onclick="pause();" />
	</ui:define>

	<ui:define name="extraControls">
		<o:commandButton value="#{messages['permit.spatial_analysis']}" onclick="#{rich:component('spatialAnalysisPanel')}.show();" />
		<o:commandButton value="#{messages['button.back2analysis']}" onclick="back2analysis();" />
	</ui:define>

	<ui:define name="body">
		<div align="center">
			<br/>
			<strong>#{messages['permit.approval_header']}</strong>
			<rich:separator lineType="solid"/>
			<br/>

			<ui:include src="/WEB-INF/includes/showHelpIncl.xhtml">
				<ui:param name="width" value="500" />
				<ui:param name="mainMessage" value="#{messages['permit.approval_help']}:" />
			</ui:include>

			<br/>
		</div>
		
		<br />
	
		<h:form>
			<rich:panel>
				<div align="center">
					<h3>#{messages['permit.approver_opinion']}</h3>
					<rich:separator lineType="solid"/>
					<br />
					<h:inputTextarea value="#{buildingPermitHelper.permit.approverOpinion}" style="width:90%" rows="3" />
				</div>
			</rich:panel>
			
			<a4j:jsFunction name="approvePermit" action="#{buildingPermitHelper.endApprovalTask}">
				<f:setPropertyActionListener value="#{true}" target="#{buildingPermitHelper.approveTransaction}" />
			</a4j:jsFunction>
			<a4j:jsFunction name="denyPermit" action="#{buildingPermitHelper.endApprovalTask}">
				<f:setPropertyActionListener value="#{false}" target="#{buildingPermitHelper.approveTransaction}" />
			</a4j:jsFunction>
			<a4j:jsFunction name="pause" action="home" />
			<a4j:jsFunction name="back2analysis" action="#{buildingPermitHelper.approvalBackToAnalysis}"/>
		</h:form>

		<br />
		<br />
		<br />

		<rich:simpleTogglePanel switchType="client" label="#{messages['permit.approval_previous_obs']}">
			<rich:panel>
				<div align="center">
					<ui:include src="/permits/includes/viewPresentationPartIncl.xhtml">
						<ui:param name="title" value="#{messages['permit.presentation_data']}" />
						<ui:param name="receptionistUserName" value="#{buildingPermitHelper.permit.receptionistUserName}" />
						<ui:param name="receptionistFullName" value="#{buildingPermitHelper.permit.receptionistFullName}" />
						<ui:param name="validityFrom" value="#{buildingPermitHelper.permit.validityFrom}" />
						<ui:param name="validityTo" value="#{buildingPermitHelper.permit.validityTo}" />
						<ui:param name="partyNationalIdentity" value="#{buildingPermitHelper.partyNationalIdentity}" />
						<ui:param name="partyName" value="#{buildingPermitHelper.partyName}" />
						<ui:param name="requestText" value="#{buildingPermitHelper.permit.requestText}" />
						<ui:param name="showAttachedFilesXhtmlPath" value="/permits/building/includes/showAttachedFiles.xhtml" />
					</ui:include>
				</div>
			</rich:panel>
	
			<br />
			<br />
			<rich:separator lineType="double"/>
			<br />
			<br />
			
			<rich:panel>
				<div align="center">
					<ui:include src="/permits/includes/viewAnalysisPartIncl.xhtml">
						<ui:param name="title" value="#{messages['permit.analysis_data']}" />
						<ui:param name="ruleGroupName" value="#{buildingPermitHelper.permit.ruleGroupName}" />
						<ui:param name="analystUserName" value="#{buildingPermitHelper.permit.analystUserName}" />
						<ui:param name="analystFullName" value="#{buildingPermitHelper.permit.analystFullName}" />
						<ui:param name="permitType" value="#{messages[buildingPermitHelper.permit.type.name()]}" />
						<ui:param name="spatialZone" value="#{buildingPermitHelper.permit.spatialZone}" />
						<ui:param name="permitObservations" value="#{buildingPermitHelper.permitObservations}" />
						<ui:param name="analystOpinion" value="#{buildingPermitHelper.permit.analystOpinion}" />
					</ui:include>
				</div>
			</rich:panel>
		</rich:simpleTogglePanel>
		
		<ui:include src="/permits/includes/spatialAnalysisPanel.xhtml" />
	</ui:define>
</ui:composition>
